using NodeCanvas.Framework;

namespace Yoozoo.Gameplay.Liberty.AI.Node
{
    public class NpcIsAmmoLow : AIConditionBaseNode
    {
        public int LowAmmoNum = 30;
        public bool IsGrenade = false;

        public BBParameter<SearchType> SearchAmmoType;
        public BBParameter<int> Id;
        
        protected override bool OnCheck()
        {
            bool result = false;
            var weaponSystem = _entity.WeaponSystem;
            Weapon weapon;

            if (IsGrenade)
            {
                weapon = weaponSystem.EquippedGrenade;
            }
            else
            {
                weapon = weaponSystem.EquippedWeapon;
            }

            if (weapon.MaxBullet < LowAmmoNum && weapon.MaxBullet != -1)
            {
                result = true;
                SearchAmmoType.value = SearchType.SearchItemBindID;
                Id.value = weapon.Config.weapon_id;
            }

            return result;
        }
    }
}